import { MiddlewareConsumer, Module, NestModule,RequestMethod } from '@nestjs/common'
import { AppController } from './app.controller'
// import { CommonModule } from './common.module'
// import { OtherModule } from './other.module'
import { DynamicConfigModule } from './dynamicConfig.module'
import { AppService } from './app.service'
import { LoggerMiddleware } from './logger.middleware'
import { loggerFunction } from './logger-function.middleware'
import { APP_FILTER } from '@nestjs/core'
import { CustomExceptionFilter } from './custom-exception.filter'

// import { LoggerModule } from './logger.module'
// import { CoreModule } from './core.module'
// import {UserController} from './user.controller'
// import {LoggerService, UseValueService, UseFactory, LoggerClassService} from './logger.service'
@Module({
  // imports: [DynamicConfigModule.forRoot('456')],
  controllers: [AppController],
  // providers: [
  //   AppService
  // ],
  // exports: [
  //   AppService
  // ]
  providers: [
    // {
    //   provide: 'SUFFIX',
    //   useValue:'suffix'
    // },
    // AppService,
    // LoggerClassService, // 单例
    // { // 单例
    //   provide: LoggerService,
    //   useClass: LoggerService
    // },
    // {
    //   provide: 'StringToken',
    //   useValue: new UseValueService('')
    // },
    
    // {
    //   provide: APP_FILTER,
    //   useClass: CustomExceptionFilter
    // }
    // {
    //   provide: 'FactoryToken',
    //   useFactory: () => new UseFactory()
    // }
  ]
})
export class AppModule{}
// export class AppModule implements NestModule{
//   configure(consumer: MiddlewareConsumer) {
//     // consumer.apply(LoggerMiddleware)
//     consumer.apply(loggerFunction)
//     // .forRoutes({
//     //   path:'config',
//     //   method: RequestMethod.GET
//     // })
//     .exclude({path: 'app/config', method: RequestMethod.GET})
//     .forRoutes(AppController)
//   }
  
// }
